﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using BusinessObjects.BussinessVoucher;
using DataObjects.Shared;
using DataObjects.StandartInterfaces.Voucher;

namespace DataObjects.ADO.SqlServer.Voucher
{
    /// <summary>
    /// 
    /// </summary>
    public class SqlServerFixedAssetArmortizationDetailDao : IFixedAssetArmortizationDetailDao
    {
        /// <summary>
        /// Takes the specified employ test.
        /// </summary>
        /// <param name="fixedAssetArmortization">The employ test.</param>
        /// <returns></returns>
        private static object[] Take(FixedAssetArmortizationDetail fixedAssetArmortization)
        {
            return new object[]  
            {
                //"@EmployID", fixedAssetArmortization.EmployId,
                //"@Name", fixedAssetArmortization.Name,
                //"@Salary", fixedAssetArmortization.Salary,
                //"@DepartmentID", fixedAssetArmortization.DepartmentId
            };
        }
        /// <summary>
        /// The make
        /// </summary>
        private static readonly Func<IDataReader, FixedAssetArmortizationDetail> Make = reader =>
          new FixedAssetArmortizationDetail
          {
              RefDetailId = reader["RefDetailID"].AsLong(),
              RefId = reader["RefID"].AsLong(),
              FixedAssetId = reader["FixedAssetID"].AsInt(),
              AccountNumber = reader["AccountNumber"].AsString(),
              CorrespondingAccountNumber = reader["CorrespondingAccountNumber"].AsString(),
              Description = reader["Description"].AsString(),
              Quantity = reader["Quantity"].AsInt(),
              Amount = reader["Amount"].AsDecimal(),
              VoucherTypeId = reader["VoucherTypeID"].AsLong(),
              DepartmentId = reader["DepartmentID"].AsLong(),
              ProjectId = reader["ProjectID"].AsLong()
              
          };

        public List<FixedAssetArmortizationDetail> GetFixedAssetArmortizationDetailsByFixedAssetArmortization(long refId)
        {
            throw new NotImplementedException();
        }


        public FixedAssetArmortizationDetail GetFixedAssetArmortizationDetail(long fixedAssetArmortizationId)
        {
            const string sql = @"uspGet_FixedAssetArmortizationDetail_ByID";
            object[] parms = { "@EmployID", fixedAssetArmortizationId };
            return Db.Read(sql, CommandType.StoredProcedure, Make, parms);
        }

        /// <summary>
        /// Inserts the fixedAssetArmortization.
        /// </summary>
        /// <param name="fixedAssetArmortization">The fixedAssetArmortization.</param>
        /// <returns></returns>
        public string InsertFixedAssetArmortizationDetail(FixedAssetArmortizationDetail fixedAssetArmortization)
        {
            const string sql = "uspInsert_FixedAssetArmortizationDetail";
            return Db.Insert(sql, CommandType.StoredProcedure, Take(fixedAssetArmortization));
        }

        /// <summary>
        /// Updates the fixedAssetArmortization.
        /// </summary>
        /// <param name="fixedAssetArmortization">The fixedAssetArmortization.</param>
        /// <returns></returns>
        public string UpdateFixedAssetArmortizationDetail(FixedAssetArmortizationDetail fixedAssetArmortization)
        {
            const string sql = "uspUpdate_FixedAssetArmortizationDetail";
            return Db.Update(sql, CommandType.StoredProcedure, Take(fixedAssetArmortization));
        }

        /// <summary>
        /// Deletes the fixedAssetArmortization.
        /// </summary>
        /// <param name="fixedAssetArmortization">The fixedAssetArmortization.</param>
        /// <returns></returns>
        public string DeleteFixedAssetArmortizationDetail(FixedAssetArmortizationDetail fixedAssetArmortization)
        {
            const string sql = @"uspDelete_FixedAssetArmortizationDetail";
            object[] parms = { "@EmployID", fixedAssetArmortization.RefDetailId };
            return Db.Delete(sql, CommandType.StoredProcedure, parms);
        }


    }

}
